using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace MapTestFramework.Common
{
    /// <summary>
    /// Represents a collection class containing test case values for a single file.
    /// This file can either be a source file or an expected file.
    /// </summary>
    public class TestCaseValueCollection : System.Collections.ObjectModel.Collection<string[]>
    {
        #region Constructor And Initializing Members

        /// <summary>
        /// Initializes a new instance of the TestCaseValueCollection class with the specified XPath expressions.
        /// </summary>
        /// <param name="xpaths">One or more XPath expressions which identify the nodes to update.</param>
        public TestCaseValueCollection(params string[] xpaths)
        {
            ExceptionHelper.CheckXPaths(xpaths);

            m_XPaths = xpaths;
            return;
        }

        #endregion

        #region Public Members

        /// <summary>
        /// Gets the XPath expressions which identify the nodes to update.
        /// </summary>
        /// <returns>Array of XPath expressions.</returns>
        public string[] GetXPaths()
        {
            return (string[]) m_XPaths.Clone();
        }
            
        #endregion

        #region Collection members

        protected override void InsertItem(int index, string[] item)
        {
            if (item == null)
                item = new string[this.GetXPaths().Length];

            ExceptionHelper.CheckValues(item, this.GetXPaths().Length, "item");

            base.InsertItem(index, item);
            return;
        }

        #endregion

        #region Helper Members

        private string[] m_XPaths = null;

        #endregion
    }
}
